//
//  OrderExtHeaderView.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/17.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "OrderExtHeaderView.h"
#import "GoodsView.h"
#import "GetAddBuyGoodsView.h"
#import "DeleteNull.h"
@interface OrderExtHeaderView()<UITextFieldDelegate>
@property(nonatomic,retain)UIDatePicker* da1;
@end

@implementation OrderExtHeaderView

{
    NSMutableArray*sumPrices;
    GoodsView*shangpingView;
    GetAddBuyGoodsView*GoodView;
    UILabel *l1;
    UILabel* gatheringInformation;
    UIView*gayView;
    UIView*myToolBar;
    BOOL isHaveDian;
    NSString*isCurrent;
    UIView*retail;
    UIView*gayView1;
    UIButton*takeExpiryDateBtn;
}
//@synthesize mDelegate;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
        myToolBar.backgroundColor=jianpancolor;
        UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
        [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:tubtnDone];
        UIButton*btnDone=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
        [btnDone setTitle:@"确定" forState:UIControlStateNormal];
        [btnDone setTitleColor:jianpancolor1 forState:UIControlStateNormal];
        btnDone .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
        [btnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:btnDone];
        myToolBar.alpha=alp;
        UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
        [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:dabtn];
        
        _headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 330)];
        [self addSubview:_headerView];
        UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 80/2)];
        view1.backgroundColor=[UIColor whiteColor];
        [_headerView addSubview:view1];
        
        UIView*gayView2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom, ScreenWidth, 10)];
        gayView2.backgroundColor=zuiqianhuiColor;
        gayView2.layer.borderWidth = 0.40;
        gayView2.layer.borderColor = qianhuiColor.CGColor;
        [_headerView addSubview:gayView2];
        
        
        UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 40, 40)];
        duogou.text=[NSString stringWithFormat:@"员工"];
        duogou.textColor=shenhuiColor;
        duogou.font=[UIFont systemFontOfSize:contenfot];
        [view1 addSubview:duogou];
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* UserName = [user1 objectForKey:@"userName"];
        
        
        
        _staffNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-300,  0,260,40)];
        [_staffNameBtn setTitle:UserName forState:UIControlStateNormal];
        _staffNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _staffNameBtn.titleLabel.textAlignment=NSTextAlignmentRight;
        [_staffNameBtn addTarget:self action:@selector(chooseUserBtn:) forControlEvents:UIControlEventTouchUpInside];
        _staffNameBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [_staffNameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [view1 addSubview:_staffNameBtn];
        UIButton*chooseUserBtn = [[UIButton alloc]init];
        chooseUserBtn.frame = CGRectMake(ScreenWidth-40,5.5, 30, 30);
        [chooseUserBtn addTarget:self action:@selector(chooseUserBtn:) forControlEvents:UIControlEventTouchUpInside];
        [chooseUserBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [view1 addSubview:chooseUserBtn];
    }
    return self;
}
//订单
-(void)setModel:(OrderExtHeaderModel *)model{
    isCurrent=@"N";
    [retail removeFromSuperview];
    [_memberView removeFromSuperview];
    [gayView1 removeFromSuperview];
    retail=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 45)];
    retail.backgroundColor=[UIColor whiteColor];
    [_headerView addSubview:retail];
    
    UILabel*type=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 45)];
    type.text=@"类型";
    type.textColor=shenhuiColor;
    type.font=[UIFont systemFontOfSize:contenfot];
    [retail addSubview:type];
    _typeBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-300,  0,260,45)];
    if ([self.type isEqualToString:@"Booking"]) {
        retail.frame=CGRectMake(0, 50, ScreenWidth, 90);
        [_typeBtn setTitle:@"预售" forState:UIControlStateNormal];
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(10,45-0.25,ScreenWidth-20, 0.40)];
        l.backgroundColor=qianhuiColor;
        [retail addSubview:l];
        UILabel*type=[[UILabel alloc]initWithFrame:CGRectMake(15, 45, ScreenWidth-30, 45)];
        type.text=@"提货时间";
        type.textColor=shenhuiColor;
        type.font=[UIFont systemFontOfSize:contenfot];
        [retail addSubview:type];
        _da1 = [[UIDatePicker alloc] init];
        [_da1 addTarget:self action:@selector(dateChanged1:) forControlEvents:UIControlEventValueChanged];
        _da1.datePickerMode = UIDatePickerModeDate;
        _da1.backgroundColor=[UIColor whiteColor];
        
        _takeExpiryDateTextFied=[[UITextField alloc]initWithFrame:CGRectMake(ScreenWidth-165,45,165,  88/2)];
        _takeExpiryDateTextFied.borderStyle = UITextBorderStyleNone;
        _takeExpiryDateTextFied.font = [UIFont systemFontOfSize: 15];
        _takeExpiryDateTextFied.textColor=qianheiColor;
        _takeExpiryDateTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
        _takeExpiryDateTextFied.placeholder = @"请选择日期"; //默认显示的字
        _takeExpiryDateTextFied.delegate = self;
        _takeExpiryDateTextFied.tag=11;
        _takeExpiryDateTextFied.text= _takeExpiryDateStr;
        _takeExpiryDateTextFied.inputView = _da1;
        _takeExpiryDateTextFied.textAlignment=NSTextAlignmentCenter;
        _takeExpiryDateTextFied.inputAccessoryView= myToolBar;
        [retail addSubview:_takeExpiryDateTextFied];
        takeExpiryDateBtn = [[UIButton alloc]init];
        takeExpiryDateBtn.frame = CGRectMake(ScreenWidth-42.5,6+45,33, 33);
        takeExpiryDateBtn.userInteractionEnabled=NO;
        [takeExpiryDateBtn setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
        [retail addSubview:takeExpiryDateBtn];

    }else if ([self.type isEqualToString:@"Retail"]) {
        [_typeBtn setTitle:@"零售" forState:UIControlStateNormal];//默认
        retail.frame=CGRectMake(0, 50, ScreenWidth, 45);
    }else{
        [_typeBtn setTitle:self.typeName forState:UIControlStateNormal];//不符合数据类型的展示
        retail.frame=CGRectMake(0, 50, ScreenWidth, 45);
    }
    _typeBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    _typeBtn.titleLabel.textAlignment=NSTextAlignmentRight;
    [_typeBtn addTarget:self action:@selector(typeBtn:) forControlEvents:UIControlEventTouchUpInside];
    _typeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_typeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [retail addSubview:_typeBtn];
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(ScreenWidth-40,7.5, 30, 30);
    jiantou.userInteractionEnabled=NO;
    [jiantou addTarget:self action:@selector(typeBtn:) forControlEvents:UIControlEventTouchUpInside];
    [jiantou setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [retail addSubview:jiantou];

    gayView1=[[UIView alloc]initWithFrame:CGRectMake(0, retail.bottom, ScreenWidth, 10)];
    gayView1.backgroundColor=zuiqianhuiColor;
    gayView1.layer.borderWidth = 0.40;
    gayView1.layer.borderColor = qianhuiColor.CGColor;
    [_headerView addSubview:gayView1];
    
    if ( [[Global getJudgeTheErrorStr:model.memberId]isEqualToString:@""]||model.memberId==NULL) {
        
        
        _memberView=[[UIView alloc]initWithFrame:CGRectMake(0, retail.bottom+10, ScreenWidth, 60)];
        _memberView.backgroundColor=[UIColor whiteColor];
        [_headerView addSubview:_memberView];
        UIView*gayView2=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 10)];
        gayView2.backgroundColor=zuiqianhuiColor;
        gayView2.layer.borderWidth = 0.40;
        gayView2.layer.borderColor = qianhuiColor.CGColor;
        [_memberView addSubview:gayView2];
        
        UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 50)];
        memberLabel.text=@"会员信息...";
        memberLabel.textColor=zhonghuiColor;
        memberLabel.numberOfLines=2;
        memberLabel.font=[UIFont systemFontOfSize:contenfot];
        [_memberView addSubview:memberLabel];
        
        
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-80,7.5,0.40, 35)];
        l.backgroundColor=qianhuiColor;
        [_memberView addSubview:l];
        
        UIButton*chooseBtn = [[UIButton alloc] initWithFrame:CGRectMake( ScreenWidth-80+12.5, 50/2-12.5, 50,25)];
        [chooseBtn setTitle:@"选择" forState:UIControlStateNormal];
        [chooseBtn.layer setCornerRadius:2];
        [chooseBtn.layer setBorderWidth:0.5];
        [chooseBtn.layer setMasksToBounds:YES];
        chooseBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [chooseBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        chooseBtn .titleLabel.font=[UIFont systemFontOfSize:13];
        [chooseBtn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_memberView addSubview:chooseBtn];
        
        
    }else{
        
        _memberView=[[UIView alloc]initWithFrame:CGRectMake(0, retail.bottom+10, ScreenWidth,  60)];
        _memberView.backgroundColor=[UIColor whiteColor];
        [_headerView addSubview:_memberView];
        UIView*gayView3=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 10)];
        gayView3.backgroundColor=zuiqianhuiColor;
        gayView3.layer.borderWidth = 0.40;
        gayView3.layer.borderColor = qianhuiColor.CGColor;
        [_memberView addSubview:gayView3];
        
        
        NSString *s = [NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
        UIFont *font = [UIFont systemFontOfSize:16];
        CGSize size = CGSizeMake(320, 2000);
        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
        UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, labelsize.width+3, 50)];
        if ([self.userName length]==0){
            memberLabel.text=@"会员信息...";
            memberLabel.textColor=zhonghuiColor;
            [memberLabel setFrame:CGRectMake(15, 0, ScreenWidth-30, 50)];
        }
        else{
            memberLabel.text=[NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
            UIImageView*Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(memberLabel.right+5, 14.5, 20, 20)];
            if (![self.sex isEqual:[NSNull null]]) {
                
                if ([self.sex isEqualToString:@"男"]) {
                    
                    
                    Seximage.image=[UIImage imageNamed:@"nan"];
                    
                }else{
                    
                    Seximage.image=[UIImage imageNamed:@"nv"];
                    
                }
                [_memberView addSubview:Seximage];
            }
            NSString *s = [NSString stringWithFormat:@"%@",   self.gradeName];
            UIFont *font = [UIFont systemFontOfSize:14];
            CGSize size = CGSizeMake(320, 2000);
            CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
            UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, labelsize.width+3, 50)];
            
            _grade=[[UILabel alloc] initWithFrame:CGRectMake(Seximage.right+5,17.5,memberLabel.width, 14)];
            _grade.text=self.gradeName;
            _grade.textColor=[UIColor whiteColor];
            _grade.textAlignment=NSTextAlignmentCenter;
            _grade.font=[UIFont systemFontOfSize:13];
            _grade.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
            [_memberView addSubview:_grade];
            
            
            
        }
        
        memberLabel.textColor=[UIColor blackColor];
        memberLabel.font=[UIFont systemFontOfSize:16];
        [_memberView addSubview:memberLabel];
        
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-80,7.5,0.40, 35)];
        l.backgroundColor=qianhuiColor;
        [_memberView addSubview:l];
        
        UIButton*sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80+12.5, 50/2-12.5, 50,25)];
        [sxBtn setTitle:@"修改" forState:UIControlStateNormal];
        [sxBtn.layer setCornerRadius:2];
        [sxBtn.layer setBorderWidth:0.5];
        [sxBtn.layer setMasksToBounds:YES];
        sxBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [sxBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        sxBtn .titleLabel.font=[UIFont systemFontOfSize:13];
        [sxBtn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_memberView addSubview:sxBtn];
        
    }
    
    NSString*totalMoney= self.dealPrice;
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:totalMoney.doubleValue]];
    
    [self.goodInfoBtn removeFromSuperview];
    self.goodInfoBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50);
    [self.goodInfoBtn addTarget:self action:@selector(goodInfoBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.goodInfoBtn setBackgroundColor:[UIColor clearColor]];
    [_headerView addSubview:self.goodInfoBtn];
    
    _weightkeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 230, 50)];
    _weightkeLabel.text=[NSString  stringWithFormat:@"共 %@ 件   ￥%@",self.quantity, formattedNumberString];
    _weightkeLabel.textColor = [UIColor colorWithRed:5.00/255.0 green:18.0/255.0 blue:40.00/255.0 alpha:1];
    _weightkeLabel.font = [UIFont systemFontOfSize:16];
    
    NSMutableAttributedString *AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString  stringWithFormat:@"共 %@ 件   ￥%@",self.quantity, formattedNumberString]];
    [AttributedStr2 addAttribute:NSFontAttributeName
     
                           value:[UIFont systemFontOfSize:13.0]
     
                           range:NSMakeRange(0, 7)];
    
    [AttributedStr2 addAttribute:NSForegroundColorAttributeName
     
                           value:zhonghuiColor
     
                           range:NSMakeRange(0, 7)];
    
    
    _weightkeLabel.attributedText = AttributedStr2;
    [self.goodInfoBtn addSubview:_weightkeLabel];
    
    UIButton*jiantou1 = [[UIButton alloc]init];
    jiantou1.frame = CGRectMake(ScreenWidth-40,10, 30, 30);
    jiantou1.userInteractionEnabled=NO;
    [jiantou1 setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [self.goodInfoBtn addSubview:jiantou1];
    
      self.currentPlan=[DeleteNull changeType:self.currentPlan];
    
    NSLog(@"self.currentPlan-----%@",self.currentPlan);
    if (![self.currentPlan isKindOfClass:[NSNull class]]){
        //    if (self.currentPlan.count>0) {
        
        
        UIView*youhuiView=[[UIView alloc] initWithFrame:CGRectMake(0, 50, ScreenWidth, 40)];
        youhuiView.backgroundColor=[UIColor whiteColor];
        [ self.goodInfoBtn addSubview:youhuiView];
        
        UILabel *l11=[[UILabel alloc] initWithFrame:CGRectMake(10,0,ScreenWidth-20, 0.40)];
        l11.backgroundColor=qianhuiColor;
        [youhuiView addSubview:l11];
        UIImage *img=[UIImage imageNamed:@"buchongxinxi"];
        UIImage *tinted = [img rt_tintedImageWithColor:[UIColor colorWithRed:255/255.0 green:51/255.0 blue:0/255.0 alpha:1.0]];
        UIImageView*image=[[UIImageView alloc] initWithFrame:CGRectMake(0, 11, 18, 18)];
        [image setImage:tinted];
//        [youhuiView addSubview:image];
        
        UILabel*conditionsContenLabel=[[UILabel alloc] initWithFrame:CGRectMake(15, 0, ScreenWidth, 40)];
        [conditionsContenLabel setText:[NSString stringWithFormat:@"%@",@"优惠"]];
        conditionsContenLabel.font=[UIFont systemFontOfSize:13];
        conditionsContenLabel.textColor=[UIColor redColor];
        [youhuiView addSubview:conditionsContenLabel];
        UILabel*conditionsConten=[[UILabel alloc] initWithFrame:CGRectMake(46, 0, 250, 40)];
        [conditionsConten setText:[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"planTitle"]]];
        conditionsConten.font=[UIFont systemFontOfSize:12];
        conditionsConten.textColor=zhonghuiColor;
        [youhuiView addSubview:conditionsConten];
        UIButton*modifyTheBtn=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-65, 50+7.5, 50, 25)];
        [modifyTheBtn setTitle:@"修改" forState:UIControlStateNormal];
        [modifyTheBtn.layer setCornerRadius:2];
        [modifyTheBtn.layer setBorderWidth:0.5];
        [modifyTheBtn.layer setMasksToBounds:YES];
        modifyTheBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [modifyTheBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        modifyTheBtn .titleLabel.font=[UIFont systemFontOfSize:13];
        [modifyTheBtn addTarget:self action:@selector(modifyTheBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self.goodInfoBtn addSubview:modifyTheBtn];
        
        UIButton*btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 90, ScreenWidth, 40)];
        [btn setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
        [self.goodInfoBtn addSubview:btn];
        UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,40, ScreenWidth-20, 0.45)];
        _hengxian.image=[UIImage imageNamed:@"hengxian"];
        [youhuiView addSubview:_hengxian];
        
        if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderDown"]||[[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderDiscount"]) {
            UILabel*sptype=[[UILabel alloc] initWithFrame:CGRectMake(15, 40, ScreenWidth, 40)];
            [sptype setText:[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptypeName"]]];
            sptype.font=[UIFont systemFontOfSize:15];
            sptype.textColor=qianheiColor;
            [youhuiView addSubview:sptype];
            UIButton*sptypeName=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-200, 90, 185, 40)];
            [sptypeName setTitle:[NSString stringWithFormat:@"-￥%.2f",[[self.currentPlan objectForKey:@"promotionPrice"]doubleValue]]   forState:UIControlStateNormal];
            [sptypeName setTitleColor:hongseColor forState:UIControlStateNormal];
            sptypeName.titleLabel.font=[UIFont systemFontOfSize:14];
            sptypeName.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
            [ self.goodInfoBtn addSubview:sptypeName];
            self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80);
           
        }else if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderGive"]||[[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderAddPrice"]){
            
       
            UILabel*sptype=[[UILabel alloc] initWithFrame:CGRectMake(15, 40, ScreenWidth, 40)];
            [sptype setText:[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptypeName"]]];
            sptype.font=[UIFont systemFontOfSize:15];
            sptype.textColor=qianheiColor;
            [youhuiView addSubview:sptype];
            UIButton*chooseBtn=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-150, 90, 110, 40)];
            [chooseBtn setTitleColor:[UIColor redColor]  forState:UIControlStateNormal];
            chooseBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
            chooseBtn .titleLabel.font=[UIFont systemFontOfSize:14];
            [self.goodInfoBtn addSubview:chooseBtn];

            
            if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"giveTypeCode"]]isEqualToString:@"GiveIntegral"]) {
                
                
                [sptype setText:[NSString stringWithFormat:@"%@",@"赠送积分"]];
                [chooseBtn setTitle:[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"memberIntegral"]] forState:UIControlStateNormal];
                chooseBtn.frame=CGRectMake(ScreenWidth-125, 90, 110, 40);
                self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80);
           
            
            
            }else  if([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"giveTypeCode"]]isEqualToString:@"GiveCoupon"]
                      ){
                [sptype setText:[NSString stringWithFormat:@"%@",@"赠送优惠券"]];
                [chooseBtn setTitle:[NSString stringWithFormat:@"面额¥ %@",[[self.currentPlan objectForKey:@"coupon"]objectForKey:@"price"]] forState:UIControlStateNormal];
                 chooseBtn.frame=CGRectMake(ScreenWidth-125, 90, 110, 40);
                self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80);

            }else{
            [chooseBtn addTarget:self action:@selector(orderGive:) forControlEvents:UIControlEventTouchUpInside];
            UIButton*chooseBtn1=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40, 94, 33, 33)];
            [chooseBtn1 setTitleColor:[UIColor clearColor]  forState:UIControlStateNormal];
            [chooseBtn1 setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
            [chooseBtn1 addTarget:self action:@selector(orderGive:) forControlEvents:UIControlEventTouchUpInside];
            [ self.goodInfoBtn addSubview:chooseBtn1];
              
       
            if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderGive"]) {
                for (int i = 0; i<[[self.currentPlan objectForKey:@"items"]count]; i++) {
                    
                    if ([[NSString stringWithFormat:@"%@",[[self.currentPlan objectForKey:@"items"][i]objectForKey:@"isCurrent"]]isEqualToString:@"Y"]) {
                        isCurrent=@"Y";
                        [chooseBtn setTitle:@"重领赠品" forState:UIControlStateNormal];
                    }
                    
                }
            }else if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderAddPrice"]){
                for (int i = 0; i<[[self.currentPlan objectForKey:@"items"]count]; i++) {
                    
                    if ([[NSString stringWithFormat:@"%@",[[self.currentPlan objectForKey:@"items"][i]objectForKey:@"isCurrent"]]isEqualToString:@"Y"]) {
                        isCurrent=@"Y";
                        [chooseBtn setTitle:@"重新换购" forState:UIControlStateNormal];
                    }
                    
                }
            }
            
            
            if ([isCurrent isEqualToString:@"Y"]) {
                
                for (int i = 0; i<[[self.currentPlan objectForKey:@"items"]count]; i++) {
                    if ([[NSString stringWithFormat:@"%@",[[self.currentPlan objectForKey:@"items"][i]objectForKey:@"isCurrent"]]isEqualToString:@"Y"]) {
                        
                        
                        UIButton*deleteBtn=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-60, 130, 60, 90)];
                        [deleteBtn setTitle:[NSString stringWithFormat:@"%@",[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"pid"]] forState:UIControlStateNormal];
                        deleteBtn.backgroundColor=[UIColor redColor];
                        [deleteBtn setTitleColor:[UIColor clearColor]  forState:UIControlStateNormal];
                        deleteBtn .titleLabel.font=[UIFont systemFontOfSize:13];
                        [deleteBtn addTarget:self action:@selector(deleteBtnBtn:) forControlEvents:UIControlEventTouchUpInside];
                        [self.goodInfoBtn addSubview:deleteBtn];
                        UILabel*delete = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-60, 130, 60, 90)];
                        delete.font=[UIFont systemFontOfSize:14];
                        delete.textAlignment=NSTextAlignmentCenter;
                        delete.textColor=[UIColor whiteColor];
                        delete.text=@"删除";
                        [self.goodInfoBtn addSubview:delete];
                        
                        
                        GoodView = [[GetAddBuyGoodsView alloc]initWithFrame:CGRectMake(0, 130, ScreenWidth, 90)];
                        GoodView.backgroundColor=[UIColor whiteColor];
                        [GoodView.headImageFull setImageWithURL:[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"imageUrl"] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
                        GoodView.headImageFull.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
                        GoodView.headImageFull.layer.borderWidth= 0.5f;
                        
                        
                        
                        NSString *tagName =[NSString stringWithFormat:@"%@",[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"tagName"]];
                        UIFont *tagNamefont1 = [UIFont systemFontOfSize:13];
                        CGSize tagNamesize1 = CGSizeMake(ScreenWidth-60, 2000);
                        CGSize tagNamelabelsize1 = [tagName sizeWithFont:tagNamefont1 constrainedToSize:tagNamesize1 lineBreakMode:NSLineBreakByCharWrapping];
                        UILabel*_productType =[[UILabel alloc]initWithFrame:CGRectMake(80, 15,  tagNamelabelsize1.width,13)];
                        _productType.textColor=[UIColor redColor];
                        [_productType.layer setCornerRadius:2];
                        _productType.text=tagName;
                        [_productType.layer setBorderWidth:0.5];
                        [_productType.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace12 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref12 = CGColorCreate(colorSpace12,(CGFloat[]){ 252/255.0, 54/255.0, 30/255.0, 1.0 });
                        [_productType.layer setBorderColor:colorref12];//边框颜色
                        _productType.font=[UIFont systemFontOfSize:10];
                        _productType.textAlignment=NSTextAlignmentCenter;
                        [GoodView addSubview:_productType];
                        
                        
                        
                        NSString *s1 =[NSString stringWithFormat:@"%@",[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"itemName"]];
                        UIFont *font1 = [UIFont systemFontOfSize:13];
                        CGSize size1 = CGSizeMake(ScreenWidth-85-tagNamelabelsize1.width-15, 2000);
                        CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                        
                        UILabel*_itemName = [[UILabel alloc]initWithFrame:CGRectMake(_productType.right+5, 15, ScreenWidth-85-tagNamelabelsize1.width-15, labelsize1.height)];
                        _itemName.numberOfLines=0;
                        _itemName.text=s1;
                        _itemName.textColor=[UIColor blackColor];
                        _itemName.font=[UIFont systemFontOfSize:13];
                        [GoodView addSubview:_itemName];
                        
                        
                        
                        UILabel*specName = [[UILabel alloc]initWithFrame:CGRectMake(_productType.right+5, 15, ScreenWidth-85-tagNamelabelsize1.width-15, 12)];
                        specName.text=[NSString stringWithFormat:@"%@",[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"specName"]];
                        specName.font=[UIFont systemFontOfSize:12];
                        specName.textColor=shenhuiColor;
                        [GoodView addSubview:specName];
                        
                        UILabel*dealPrice =  [[UILabel alloc]initWithFrame:CGRectMake(_productType.right+5, 60, ScreenWidth-85-tagNamelabelsize1.width-15, 12)];
                        dealPrice.font=[UIFont systemFontOfSize:12];
                        dealPrice.textColor=shenhuiColor;
                        NSNumber*Total =[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"salePrice"];
                        
                        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                        [numberFormatter setPositiveFormat:@"###,##0.00;"];
                        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
                        dealPrice.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
                        dealPrice.textColor=zhonghuiColor;
                        [GoodView addSubview:dealPrice];
                        
                        GoodView.quantity.text=[NSString stringWithFormat:@"x %@",[[[self.currentPlan objectForKey:@"items"] objectAtIndex:i] objectForKey:@"quantity"]];
                        
                        
                        [self.goodInfoBtn addSubview:GoodView];
                        UISwipeGestureRecognizer*leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
                        UISwipeGestureRecognizer*rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
                        
                        leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
                        rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
                        
                        [GoodView addGestureRecognizer:leftSwipeGestureRecognizer];
                        [GoodView addGestureRecognizer:rightSwipeGestureRecognizer];
                        
                    }
                    
                }
                
                
                self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80+90);
                
                
                
            }else{
                
                self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80);
                if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderGive"]) {
                    
                    
                    if ([[self.currentPlan objectForKey:@"items"]count]>0) {
                    
                     [chooseBtn setTitle:@"领赠品" forState:UIControlStateNormal];
                    }else{
                    [chooseBtn setTitle:@"未达标" forState:UIControlStateNormal];
                    [chooseBtn1 setUserInteractionEnabled:NO];

                    }
                    
                    
                    
                    
                }else if ([[NSString stringWithFormat:@"%@",[self.currentPlan objectForKey:@"sptype"]]isEqualToString:@"orderAddPrice"]){
                  
                    
                    if ([[self.currentPlan objectForKey:@"items"]count]>0) {
                        
                        [chooseBtn setTitle:@"去换购" forState:UIControlStateNormal];
                    }else{
                        [chooseBtn1 setUserInteractionEnabled:NO];
                        [chooseBtn setTitle:@"未达标" forState:UIControlStateNormal];
                    }
                }
                
            }
            
            
            
            }
            
            
            
            
        }else{
            //            self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom+10, ScreenWidth, 50+80);
            
        }
        
    }else{
        
        self.goodInfoBtn.frame= CGRectMake(0, _memberView.bottom, ScreenWidth, 50+80);
        
    }
    
    
    //    }else{
    //
    //
    //    }
    [gayView removeFromSuperview];
    [_jiantou removeFromSuperview];
    [l1 removeFromSuperview];
    [gatheringInformation removeFromSuperview];
    gayView=[[UIView alloc]initWithFrame:CGRectMake(0, self.goodInfoBtn.bottom, ScreenWidth, 10)];
    gayView.backgroundColor=zuiqianhuiColor;
    gayView.layer.borderWidth = 0.40;
    gayView.layer.borderColor = qianhuiColor.CGColor;
    [_headerView addSubview:gayView];
    gatheringInformation=[[UILabel alloc]initWithFrame:CGRectMake(0, self.goodInfoBtn.bottom+10, ScreenWidth, 45)];
    gatheringInformation.text=@"    收款信息";
    gatheringInformation.textColor=qianheiColor;
    gatheringInformation.layer.borderColor = qianhuiColor.CGColor;
    gatheringInformation.backgroundColor=[UIColor whiteColor];
    gatheringInformation.font=[UIFont systemFontOfSize:15];
    [_headerView addSubview:gatheringInformation];
    
    l1=[[UILabel alloc] initWithFrame:CGRectMake(15,gatheringInformation.bottom-0.40,ScreenWidth-30, 0.45)];
    l1.backgroundColor=qianhuiColor;
    [_headerView addSubview:l1];
    
    _headerView.frame=CGRectMake(0, 0, ScreenWidth, gatheringInformation.bottom+45);
    
    
    [_discountTextFied removeFromSuperview];
    [_discountRateSatBtn removeFromSuperview];
    _discountTextFied=[[UITextField alloc]initWithFrame:CGRectMake(15,l1.bottom, ScreenWidth-100,45)];
    _discountTextFied.borderStyle = UITextBorderStyleNone;
    _discountTextFied.keyboardType = UIKeyboardTypeDecimalPad;
    _discountTextFied.font = [UIFont systemFontOfSize: contenfot];
    _discountTextFied.textColor=[UIColor blackColor];
    _discountTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    _discountTextFied.tag=1;
    _discountTextFied.placeholder = @"请输入整单折扣金额"; //默认显示的字
    _discountTextFied.delegate = self;
    [_discountTextFied setUserInteractionEnabled:YES];
    _discountTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
    [_headerView addSubview:_discountTextFied];
    _discountTextFied.inputAccessoryView = myToolBar;
    _discountRateSatBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-100,l1.bottom, 60,50)];
    _discountRateSatBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    _discountRateSatBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_discountRateSatBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_headerView addSubview:_discountRateSatBtn];
    
    _jiantou = [[UIButton alloc]init];
    _jiantou.frame = CGRectMake(ScreenWidth-40,l1.bottom+10, 30, 30);
    [_jiantou setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [_headerView addSubview:_jiantou];
    
    
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    if (textField.tag == 1)
    {
        
        if (range.location >= 9){
            return NO;
        }
        if ([textField.text rangeOfString:@"."].location==NSNotFound) {
            isHaveDian=NO;
        }
        if ([string length]>0)
        {
            unichar single=[string characterAtIndex:0];//当前输入的字符
            if ((single >='0' && single<='9') || single=='.')//数据格式正确
            {
                //首字母不能为0和小数点
                if([textField.text length]==0){
                    if(single == '.'){
                        
                        [textField.text stringByReplacingCharactersInRange:range withString:@""];
                        return NO;
                        
                    }
                    //                    if (single == '0') {
                    //                        // [self alertView:@"亲，第一个数字不能为0"];
                    //                        [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    //                        return NO;
                    //
                    //                    }
                }
                if (single=='.')
                {
                    if(!isHaveDian)//text中还没有小数点
                    {
                        isHaveDian=YES;
                        return YES;
                    }else
                    {
                        //[self alertView:@"亲，您已经输入过小数点了"];
                        [textField.text stringByReplacingCharactersInRange:range withString:@""];
                        return NO;
                    }
                }
                else
                {
                    if (isHaveDian)//存在小数点
                    {
                        //判断小数点的位数
                        NSRange ran=[textField.text rangeOfString:@"."];
                        int tt=range.location-ran.location;
                        if (tt <= 2){
                            return YES;
                        }else{
                            //[self alertView:@"亲，您最多输入两位小数"];
                            return NO;
                        }
                    }
                    else
                    {
                        return YES;
                    }
                }
            }else{//输入的数据格式不正确
                //[self alertView:@"亲，您输入的格式不正确"];
                [textField.text stringByReplacingCharactersInRange:range withString:@""];
                return NO;
            }
        }
        
        
        
    }
    
    
    
    return YES;
    
    
}


-(void)goodInfoBtnClick
{
   
    
    if ([self.delegate respondsToSelector:@selector(goodInfoButtonClick)]) {
        [self.delegate goodInfoButtonClick];
    }
}
-(void)inforemationBtn:(UIButton*)sender{
    
    if ([self.delegate respondsToSelector:@selector(information)]) {
        [self.delegate information];
    }
    
    //    [mDelegate information:@""];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    if (textField.tag==11){
      
            if (textField.text.length<1) {
                NSDateFormatter* df = [[NSDateFormatter alloc] init];
                [df setDateFormat:@"yyyy-MM-dd"];
                _takeExpiryDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
            }
        

        [takeExpiryDateBtn setImage:[UIImage imageNamed:@"shouqi_shang"] forState:UIControlStateNormal];
        
    }else{
         [takeExpiryDateBtn setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
        [_delegate textFieldEditing:[NSString stringWithFormat:@"%ld", textField.tag]];
    
    }
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    
    
    if (textField.tag==11){
       
        
    }else{
       
        [_delegate textFiedkey:@""];
    
    }
    return self;
}          // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end


-(void)OnTapDone{
    [takeExpiryDateBtn setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
    [_takeExpiryDateTextFied resignFirstResponder];
    [_delegate OnTapDonekey:@""];
    
}
-(void)chooseUserBtn:(UIButton*)sender{
    [_delegate chooseUserBtn:@""];
    
}

-(void)typeBtn:(UIButton*)sender{
    
   [_delegate typeBtn:@""];
    
}
-(void)orderGive:(UIButton*)sender{
    
    
    if ([sender.titleLabel.text isEqualToString:@"未达标"]) {
     
    }else{
    [_delegate orderGive:@""];
    }
}
-(void)modifyTheBtn:(UIButton*)sender{
    
    [_delegate modifyTheBtn:@""];
    
}
-(void)chooseBtn:(UIButton*)sender{
    
    if ([self.delegate respondsToSelector:@selector(chooesBtn)]) {
        [self.delegate chooesBtn];
    }
    //    [mDelegate chooesBtn:@""];
}
//自定义
-(void)setTheCustomExtHeaderModel:(TheCustomExtHeaderModel *)TheCustomExtHeaderModel{
    
    if ( [[Global getJudgeTheErrorStr:TheCustomExtHeaderModel.memberId]isEqualToString:@""]||TheCustomExtHeaderModel.memberId==NULL) {
        _memberView=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 50)];
        _memberView.backgroundColor=[UIColor whiteColor];
        [_headerView addSubview:_memberView];
        UIView*gayView2=[[UIView alloc]initWithFrame:CGRectMake(0, _memberView.bottom, ScreenWidth, 10)];
        gayView2.backgroundColor=zuiqianhuiColor;
        gayView2.layer.borderWidth = 0.40;
        gayView2.layer.borderColor = qianhuiColor.CGColor;
        [_headerView addSubview:gayView2];
        
        UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 50)];
        memberLabel.text=@"会员信息...";
        memberLabel.textColor=zhonghuiColor;
        memberLabel.center=_memberView.center;
        memberLabel.numberOfLines=2;
        memberLabel.font=[UIFont systemFontOfSize:contenfot];
        [_headerView addSubview:memberLabel];
        
        
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-80,7.5,0.40, 35)];
        l.backgroundColor=qianhuiColor;
        [_memberView addSubview:l];
        
        UIButton*chooseBtn = [[UIButton alloc] initWithFrame:CGRectMake( ScreenWidth-80+12.5, 50/2-12.5, 50,25)];
        [chooseBtn setTitle:@"选择" forState:UIControlStateNormal];
        [chooseBtn.layer setCornerRadius:2];
        [chooseBtn.layer setBorderWidth:0.5];
        [chooseBtn.layer setMasksToBounds:YES];
        chooseBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [chooseBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        chooseBtn .titleLabel.font=[UIFont systemFontOfSize:13];
        [chooseBtn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_memberView addSubview:chooseBtn];
        
        
    }else{
        
        _memberView=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth,  50)];
        _memberView.backgroundColor=[UIColor whiteColor];
        [_headerView addSubview:_memberView];
        UIView*gayView2=[[UIView alloc]initWithFrame:CGRectMake(0, _memberView.bottom, ScreenWidth, 10)];
        gayView2.backgroundColor=zuiqianhuiColor;
        gayView2.layer.borderWidth = 0.40;
        gayView2.layer.borderColor = qianhuiColor.CGColor;
        [_headerView addSubview:gayView2];
        
        
        NSString *s = [NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
        UIFont *font = [UIFont systemFontOfSize:16];
        CGSize size = CGSizeMake(320, 2000);
        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
        UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, labelsize.width+3, 50)];
        memberLabel.text=[NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
        memberLabel.textColor=[UIColor blackColor];
        memberLabel.font=[UIFont systemFontOfSize:16];
        [_memberView addSubview:memberLabel];
        
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-80,7.5,0.40, 35)];
        l.backgroundColor=qianhuiColor;
        [_memberView addSubview:l];
        
        UIButton*sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80+12.5, 50/2-12.5, 50,25)];
        [sxBtn setTitle:@"修改" forState:UIControlStateNormal];
        [sxBtn.layer setCornerRadius:2];
        [sxBtn.layer setBorderWidth:0.5];
        [sxBtn.layer setMasksToBounds:YES];
        sxBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [sxBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        sxBtn .titleLabel.font=[UIFont systemFontOfSize:13];

        [sxBtn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_memberView addSubview:sxBtn];
        
        UIImageView*Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(memberLabel.right+5, 14, 20, 20)];
        if (![self.sex isEqual:[NSNull null]]) {
            
            if ([self.sex isEqualToString:@"男"]) {
                
                
                Seximage.image=[UIImage imageNamed:@"nan"];
                
            }else{
                
                Seximage.image=[UIImage imageNamed:@"nv"];
                
            }
            [_memberView addSubview:Seximage];
        }}
    
    
    
    NSString*totalMoney= self.prices;
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:totalMoney.doubleValue]];
    
    _weightkeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, _memberView.bottom+10, 230, 50)];
    _weightkeLabel.text=[NSString  stringWithFormat:@"自定义商品   总计￥%@", formattedNumberString];
    _weightkeLabel.textColor = [UIColor colorWithRed:5.00/255.0 green:18.0/255.0 blue:40.00/255.0 alpha:1];
    _weightkeLabel.font = [UIFont systemFontOfSize:16];
    NSMutableAttributedString *AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString  stringWithFormat:@"自定义商品   总计￥%@", formattedNumberString]];
    [AttributedStr2 addAttribute:NSFontAttributeName
     
                           value:[UIFont systemFontOfSize:13.0]
     
                           range:NSMakeRange(0, 11)];
    
    [AttributedStr2 addAttribute:NSForegroundColorAttributeName
     
                           value:zhonghuiColor
     
                           range:NSMakeRange(0, 11)];
    
    
    _weightkeLabel.attributedText = AttributedStr2;
    [_headerView addSubview:_weightkeLabel];
    
    gayView=[[UIView alloc]initWithFrame:CGRectMake(0, _weightkeLabel.bottom, ScreenWidth, 10)];
    gayView.backgroundColor=zuiqianhuiColor;
    gayView.layer.borderWidth = 0.40;
    gayView.layer.borderColor = qianhuiColor.CGColor;
    [_headerView addSubview:gayView];
    
    gatheringInformation=[[UILabel alloc]initWithFrame:CGRectMake(0, _weightkeLabel.bottom+10, ScreenWidth, 45)];
    gatheringInformation.text=@"    收款信息";
    gatheringInformation.textColor=[UIColor blackColor];
    gatheringInformation.layer.borderColor = qianhuiColor.CGColor;
    gatheringInformation.backgroundColor=[UIColor whiteColor];
    gatheringInformation.font=[UIFont systemFontOfSize:15];
    [_headerView addSubview:gatheringInformation];
    
    l1=[[UILabel alloc] initWithFrame:CGRectMake(10,gatheringInformation.bottom-0.40,ScreenWidth-20, 0.45)];
    l1.backgroundColor=qianhuiColor;
    [_headerView addSubview:l1];
    
    _headerView.frame=CGRectMake(0, 0, ScreenWidth, gatheringInformation.bottom+45);
    [_discountTextFied removeFromSuperview];
    [_discountRateSatBtn removeFromSuperview];
    _discountTextFied=[[UITextField alloc]initWithFrame:CGRectMake(15,l1.bottom, ScreenWidth-100,45)];
    _discountTextFied.borderStyle = UITextBorderStyleNone;
    _discountTextFied.keyboardType = UIKeyboardTypeDecimalPad;
    _discountTextFied.font = [UIFont systemFontOfSize: contenfot];
    _discountTextFied.textColor=[UIColor blackColor];
    _discountTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    _discountTextFied.tag=1;
    _discountTextFied.placeholder = @"请输入整单折扣金额"; //默认显示的字
    _discountTextFied.delegate = self;
    [_discountTextFied setUserInteractionEnabled:YES];
    _discountTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
    [_headerView addSubview:_discountTextFied];
    _discountTextFied.inputAccessoryView = myToolBar;
    _discountRateSatBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-100,l1.bottom, 60,50)];
    _discountRateSatBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
    _discountRateSatBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_discountRateSatBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_headerView addSubview:_discountRateSatBtn];
    _jiantou = [[UIButton alloc]init];
    _jiantou.frame = CGRectMake(ScreenWidth-40,l1.bottom+10, 30, 30);
    [_jiantou setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [_headerView addSubview:_jiantou];
    //    _headerView.frame=CGRectMake(0, 0, ScreenWidth, gatheringInformation.bottom+45);
}
-(void)deleteBtnBtn:(UIButton*)sender{
    
    [_delegate deleteBtnBtn:[NSString stringWithFormat:@"%@",sender.titleLabel.text]];
    
}
-(void)dateChanged1:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([_takeExpiryDateTextFied isFirstResponder])
    {
        _takeExpiryDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        _takeExpiryDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}
- (void)handleSwipes:(UISwipeGestureRecognizer *)sender
{
    
    
    if (sender.direction == UISwipeGestureRecognizerDirectionLeft) {
        [UIView beginAnimations:@"rotation" context:(__bridge void * _Nullable)(GoodView)];
        [UIView setAnimationDuration:0.45];
        
        GoodView.frame = CGRectMake( -60 ,GoodView.frame.origin.y , GoodView.frame.size.width, GoodView.frame.size.height);
        
        
        [UIView commitAnimations];
        
        
    }
    
    if (sender.direction == UISwipeGestureRecognizerDirectionRight) {
        
        [UIView beginAnimations:@"rotation" context:(__bridge void * _Nullable)(GoodView)];
        [UIView setAnimationDuration:0.45];
        GoodView.frame = CGRectMake( 0 , GoodView.frame.origin.y , GoodView.frame.size.width, GoodView.frame.size.height);
        [UIView commitAnimations];
    }
}

@end
